import cv2
import os
import sys

if len(sys.argv) < 2:
    print('usage: ' + sys.argv[0] + ' path_to_images')
    sys.exit(-1)

image_path = sys.argv[1]
images = os.listdir(image_path)
images.sort()

img0 = cv2.imread(image_path + '/' + images[0])
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
# fourcc = cv2.VideoWriter_fourcc(0x00000021) 
writer = cv2.VideoWriter('test.mp4', fourcc, 30, (640, 480))

if not writer.isOpened():
    sys.exit(-1)

print(len(images))
print(images[:10])

for image in images:
    full_path = image_path + '/' + image
    img_original = cv2.imread(full_path)
    img=cv2.resize(img_original,(640,480),interpolation=cv2.INTER_CUBIC)
    cv2.imshow('images', img)
    cv2.waitKey(30)
    writer.write(img)

writer.release()
